package fragments.FragmentBase;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.qozix.tileview.TileView;

/**
 * Created by Administrator on 2015/5/1.
 */
public class TileViewFragment extends Fragment{
    private TileView tileView;

    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        tileView = new TileView(getActivity());
        return super.onCreateView(inflater,container,savedInstanceState);
    }

    @Override
    public void onPause() {
        super.onPause();
        tileView.clear();
    }

    @Override
    public void onResume() {
        super.onResume();
        tileView.resume();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        tileView.destroy();
        tileView = null;
    }

    public TileView getTileView() {
        return tileView;
    }

    public void frameTo(final double x,final double y) {
        getTileView().post(new Runnable() {
            @Override
            public void run() {
                 getTileView().moveToAndCenter(x,y);
            }
        });
    }
}
